<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="__STATIC__plug/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__STATIC__admin.css?v=0.11" media="all" />
</head>

<body>
    <div class="container">
        <div class="bg"></div>
        <div class="login-bd">
            <div class="login">
                <div class="layui-form" lay-filter="login">
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="username" lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">密码</label>
                        <div class="layui-input-inline">
                            <input type="password" name="password" lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">验证码</label>
                        <div class="layui-input-inline">
                            <input type="text" name="vertify" lay-verify="required" placeholder="请输入验证码" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid" style="padding: 0!important;height:38px;">
                            <img src="{:url('index/verify')}" alt="验证码" id="captcha" style="cursor: pointer;height: 100%;" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <div class="layui-input-inline">
                            <button class="layui-btn layui-btn-normal layui-btn-fluid" lay-submit="" lay-filter="login">登录</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="__STATIC__plug/layui/layui.js"></script>
<script type="text/javascript">
layui.use(['form', 'layer'], function() {
    var $ = layui.jquery,
    	layer = layui.layer,
        form = layui.form;
    $("#captcha").on('click',function(){
        $(this).attr('src',"{:url('index/verify')}");
    })
    form.on("submit(login)", function(data) {
    	layer.load(1, {
            shade: [0.1,'#ddd'] //0.1透明度的白色背景
        });
        $.ajax({
            url:"{:url('index/login')}",
            data:data.field,
            type:"POST",
            dataType:'json',
            success:function(res){
                layer.closeAll('loading');
                if( res.err == 1 ){
                    layer.msg(res.content,{icon:5});
                    return false;
                }
                layer.msg(res.content, {icon: 1,time: 1000}, function(){
                    window.location.href = '{:url("index/index")}';
                });
            },
            error:function(){
                layer.msg("ERROR",{icon:5});
            },
            complete:function(){
                $("#captcha").click()
            }
        });
        return false;
    })
})
</script>

</html>